<template>
  <!-- 工单信息 -->
  <el-form
    :inline="true"
    ref="formData"
    :model="formData"
    :rules="rules"
    label-width="100px"
    label-position="right"
  >
    <el-row>
      <el-col :span="12">工单信息</el-col>
    </el-row>
    <el-divider content-position="center"></el-divider>
    <el-row>
      <el-col :span="6">
        <el-form-item
          label="工单编号:"
          prop="workOrderCode"
        >
          <el-input
            clearable
            disabled
            v-model="formData.workOrderCode"
          />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item
          label="单据日期:"
          prop="receiptsTime"
        >
          <el-date-picker
            v-model="formData.receiptsTime"
            disabled
            type="date"
            style="width: 195px"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择"
          ></el-date-picker>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item
          label="预计交车:"
          prop="predictDeliveryDate"
        >
          <el-date-picker
            v-model="formData.predictDeliveryDate"
            type="datetime"
            style="width: 195px"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择"
          ></el-date-picker>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item
          label="故障描述:"
          prop="faultDesc"
        >
          <el-input
            clearable
            v-model="formData.faultDesc"
            class="w-200"
          />
        </el-form-item>
      </el-col>

      <el-col :span="12">
        <el-form-item
          label="工单备注:"
          prop="remark"
        >
          <el-input
            clearable
            v-model="formData.remark"
            class="w-200"
          />
        </el-form-item>
      </el-col>

    </el-row>
  </el-form>
</template>
<script>
import { OilNum, CarModel } from '@/components/index' //导入组件库
import { synthesizeGetWorkOrderCode } from '@/api/after-sale/workOrderManage/comprehensive';//综合单api
import { getDict, objectAssignment } from '@/utils'
import moment from 'moment';
export default {
  components: {
    OilNum, CarModel
  },
  props: {
    formValue: {
      type: Object,
      default: () => { return {} },
    },
    workOrderType: {
      type: Number,
      default: 1,//1 快速单 2 综合单
    }
  },
  watch: {
    formValue: {
      deep: true,
      handler (newValue, oldValue) {
        this.formData = objectAssignment(this.formData, {
          ...newValue,
        });
      },
    },
  },
  data () {
    return {
      formData: {
        workOrderCode: '',//	string工单编号
        receiptsTime: '',//	string($date-time)单据日期
        predictDeliveryDate: '',//	string($date-time)预计交车时间
        faultDesc: '',//故障描述
        remark: '',//工单备注

      },
      rules: {
        workOrderCode: [{ required: true, message: '请输入', trigger: 'blur', },],
        receiptsTime: [{ required: true, message: '请输入', trigger: 'blur', },],
        faultDesc: [{ required: true, message: '请输入', trigger: 'blur', },],
        predictDeliveryDate: [{ required: true, message: '请选择', trigger: 'blur', },],


      },
    }
  },
  async created () {
    this.formData.receiptsTime=moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
    let { data } = await synthesizeGetWorkOrderCode();
    this.formData.workOrderCode = data
  }
}
</script>
